package com.yjq.pojo;

import java.util.Scanner;

/**
 * @author 尹嘉琪
 * @create 2021-12-09 21:30
 */
public class UserControl {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        boolean flag = true;
        int input;
        double width; // 宽
        double height; // 高
        double hypotenuse; // 斜边长
        while (flag) {
            System.out.println("当前图形可供选择：");
            System.out.println("1.矩形   2.三角形   3.其他   4.退出");
            System.out.println("请输入图形：");
            input = sc.nextInt();
            switch (input) {
                case 1:
                    while (true) {
                        System.out.print("请输入宽：");
                        width = sc.nextDouble();
                        System.out.print("请输入高：");
                        height = sc.nextDouble();
                        Rectangle rectangle = new Rectangle(width, height);
                        boolean isRectangle = rectangle.isRectangle();
                        if (isRectangle) {
                            System.out.println(rectangle.printMessage());
                            System.out.println();
                            break;
                        }
                        System.out.println("请重新输入");
                    }
                    break;
                case 2:
                    while(true) {
                        System.out.print("请输入边长：");
                        width = sc.nextDouble();
                        System.out.print("请输入边长：");
                        height = sc.nextDouble();
                        System.out.print("请输入边长：");
                        hypotenuse = sc.nextDouble();
                        Triangle triangle = new Triangle(width, height, hypotenuse);
                        boolean isTriangle = triangle.isTriangle();
                        if (isTriangle) {
                            System.out.println(triangle.printMessage());
                            System.out.println();
                            break;
                        }
                        System.out.println("请重新输入");
                    }
                    break;
                case 3:
                    System.out.println("正在开发中");
                    break;
                case 4:
                    sc.close();
                    flag = false;
                    System.out.println("退出程序！");
                    break;
                default:
                    break;
            }
        }
    }
}
